package com.bw.controller;

import com.bw.entity.Roleadm;
import com.bw.entity.TbUser;
import com.bw.service.PortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class PortController {

    @Autowired
    private PortService studentService;

      //用户登录
      @PostMapping("login")
      public String index(@RequestBody TbUser tbuser){
          TbUser tbUser = studentService.login(tbuser);
          if(tbUser!=null){
              System.out.println("1111111111111111111111111111111");
              return "ok";
          }
          return "no";
      }

    //接口列表
    @RequestMapping("portlist")
    public List portlist(@RequestParam("mohu")String mohu){
        System.out.println(mohu);
        return this.studentService.portlist(mohu);
    }
    //接口详情
    @RequestMapping("portcontext")
    public List portcontext(@RequestParam("qxqid")int qxqid){
          return this.studentService.portcontext(qxqid);
    }
    //接口入参字段
   @RequestMapping("rcport")
    public List rcport(@RequestParam("rcid")int rcid,@RequestParam("pdid")int pdid){
       return this.studentService.rcport(rcid,pdid);
   }
    //接口出参字段
    @RequestMapping("ccport")
    public List ccport(@RequestParam("ccid")int ccid,@RequestParam("pdid")int pdid){
        return this.studentService.ccport(ccid,pdid);
    }
    //用户管理
    @RequestMapping("rolelist")
    public List rolelist(@RequestParam("mohu")String mohu){
        System.out.println(mohu);
        return this.studentService.rolelist(mohu);
    }
    //用户管理添加
    @RequestMapping("admadds")
    public Roleadm admadds(@RequestBody Roleadm roleadm){
        System.out.println(roleadm);
        return this.studentService.admadds(roleadm);
    }
    @RequestMapping("admdel")
    public String del(@RequestParam("id") String id){
        String[] ids=id.split(",");
        for (String aa:ids){
            this.studentService.del(aa);
        }
        return "删除成功";
    }
    @RequestMapping("findByadma")
    public Roleadm findByadma(@RequestParam("id") int id){
        Roleadm t=this.studentService.findByadma(id);
        return t;
    }
    //修改用户信息
    @RequestMapping("updateByadmaKey")
    public void updateByadmaKey(@RequestBody Roleadm adma){
        this.studentService.updateByadmaKey(adma);
    }
    @RequestMapping("requesthead")//请求头
    public List requesthead(@RequestParam("shicid")int shicid,@RequestParam("interid")int interid){
          return this.studentService.requesthead(shicid,interid);
    }
    @RequestMapping("requestbody")//请求头
    public List requestbody(@RequestParam("shicid")int shicid,@RequestParam("interid")int interid){
        return this.studentService.requestbody(shicid,interid);
    }
    //echarts统计图成功失败次数
    @RequestMapping("Successorfailure")
    public List Successorfailure(){
          return this.studentService.Successorfailure();
    }
}
